<template>
	<view>
		<!-- 搜索 -->
		<!-- <uni-search-bar placeholder="请输入您要查找的课程名称" cancelText="搜索" radius="12" bgColor="#FAFAFA" borderColor="#FAFAFA"
		 @confirm="confirm" /> -->
		<view class="cont">
			<view class="left">
				<view class="listCont" v-for="(item,index) in stariList" :key="index" @click="leftActive(index)">
					<view :class="['cont-left', index == contIndex ? 'cont-left-active' : '']">{{item.label_name}}</view>
				</view>
			</view>
			<view class="right">
				<view class="right-list" v-if="val.sub_list && val.sub_list.length > 0" v-for="(val,key) in sublabelList" :key="key">
					<view class="right-list-title">{{val.label_name}}</view>
					<view class="right-list-cont">
						<navigator hover-class="none" :url="'schoolList?school_label_id='+cont.school_label_id" v-for="(cont,num) in val.sub_list"
						 :key="num">{{cont.label_name}}</navigator>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				contIndex: 0,
				stariList: [],
				sublabelList: []
			}
		},
		onShow() {
			this.$zapi.apiPost('user/shakeschool.Lists/sellabel').then(res => {
				if (res.data.code == 200) {
					this.stariList = res.data.data;
					this.stariList.unshift({
						fid: 0,
						label_name: "全部",
						path: "0",
						school_label_id: 0
					});
					this.getsublabel();
				}
			});
		},
		methods: {
			getsublabel: function() {
				var data = {
					fid: this.stariList[this.contIndex].school_label_id
				}
				if(this.contIndex == 0) {
					data.rank = 2
				}
				this.$zapi.apiPost('user/shakeschool.Lists/sellabel', data).then(res => {
					if (res.data.code == 200) {
						this.sublabelList = res.data.data;
					}
				});
			},
			confirm(e) {
				console.log(e.value);
			},
			leftActive(index) {
				this.contIndex = index;
				this.getsublabel();
			}
		}
	}
</script>

<style lang="scss">
	page {
		background-color: #FAFAFA;
	}

	.cont {
		// margin: 152upx 30upx 180upx 0;
		margin: 30upx 30upx 180upx 0;
		display: flex;
	}

	.listCont {
		display: flex;

		.cont-left {
			width: 120upx;
			color: #333333;
			font-size: 30upx;
			line-height: 1.2;
			padding: 40upx;
			background-color: #FFFFFF;
			margin-right: 20upx;
		}

		.cont-left-active {
			color: #FF9900;
			background-color: #FAFAFA;
		}
	}

	.right {
		width: calc(100% - 220upx);

		.right-list {
			.right-list-title {
				color: #333333;
				font-size: 32upx;
			}

			.right-list-title:before {
				content: '|';
				width: 4upx;
				height: 36upx;
				color: #FF9900;
				margin-right: 10upx;
				background-color: #FF9900;
			}

			.right-list-cont {
				display: flex;
				justify-content: flex-start;
				align-items: center;
				flex-wrap: wrap;
				text-align: center;
				background-color: #FFFFFF;
				padding: 20upx;
				margin: 20upx auto 30upx;

				& navigator {
					color: #333333;
					font-size: 26upx;
					min-width: 30%;
					margin: 10upx calc(10%/6);
				}
			}
		}
	}
</style>
